package org.project.task.controller;

import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.project.task.common.R;
import org.project.task.service.ProjectService;
import org.project.task.service.TaskService;
import org.project.task.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/home")
public class HomeController {
    @Autowired
    private UserService userService;
    @Autowired
    private ProjectService projectService;
    @Autowired
    private TaskService taskService;

    @GetMapping("/index")
    public R<Map<Object, Object>> index() {
        Long userNum = userService.count();
        Long projectNum = projectService.count();
        Long taskNum = taskService.count();
        Map<Object, Object> map = MapUtil.builder()
                .put("projectNum", projectNum)
                .put("taskNum", taskNum)
                .put("userNum", userNum)
                .build();
        return new R<Map<Object, Object>>().success(map);
    }
}
